//
//  RCDBaseViewController.m
//  BaseProject
//
//  Created by 任辰东 on 2018/7/11.
//  Copyright © 2018年 任辰东. All rights reserved.
//

#import "RCDBaseViewController.h"
#import "UIImage+Color.h"


@interface RCDBaseViewController ()
@end

@implementation RCDBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = UIColorFromHex(kColorBG);
    [UINavigationBar appearance].translucent = NO;
    self.navigationController.navigationBar.translucent = NO;
//    if (@available(iOS 15.0, *)) {
//            UINavigationBarAppearance *navigationBarAppearance = [[UINavigationBarAppearance alloc]init];
//            
//            [navigationBarAppearance setBackgroundImage:[UIImage imageWithColor:UIColorFromHex(kColorMain) size:CGSizeMake(kScreenWidth, kNavitionBarHeight)]];
//            navigationBarAppearance.titleTextAttributes = @{NSForegroundColorAttributeName:UIColorFromHex(kColorWhite),NSFontAttributeName:UIFontSize(20)};
//            [navigationBarAppearance setShadowImage:[UIImage imageWithColor:UIColorFromHex(kColorMain) size:CGSizeMake(kScreenWidth, kOnePixel)]];
//            self.navigationController.navigationBar.scrollEdgeAppearance = navigationBarAppearance;
//            self.navigationController.navigationBar.standardAppearance = navigationBarAppearance;
//            [navigationBarAppearance configureWithOpaqueBackground];
//        [navigationBarAppearance configureWithTransparentBackground];
//    }else{
//        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:UIColorFromHex(kColorMain) size:CGSizeMake(kScreenWidth, kNavitionBarHeight)] forBarMetrics:UIBarMetricsDefault];
//        [self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:UIColorFromHex(kColorLine) size:CGSizeMake(kScreenWidth, kOnePixel)]];
//    }
    
    if (self.navigationController.viewControllers.count > 1) {
        [self setNavLeftItemWithImage:UIImageWithName(@"back_white") highlightImg:nil];
    }
    if (self.tabBarController == nil && kKeyWindow.rootViewController != self.navigationController) {
        [self setNavLeftItemWithImage:UIImageWithName(@"back_white") highlightImg:nil];
    }
    
    self.edgesForExtendedLayout = UIRectEdgeBottom;
    
//    self.view.backgroundColor = UIColorFromHex(kColorWhite);
    
    [self setupViews];
    
    [self setupLayout];
}

- (void)setupViews
{
    
}

- (void)setupLayout
{
    
}

- (void)dealloc
{
    if (self)
    {
        DLog(@"释放内存空间: %@", NSStringFromClass(self.class));
    }
}

- (UIStatusBarStyle)preferredStatusBarStyle{
    
    return UIStatusBarStyleLightContent;
}

- (BOOL)prefersStatusBarHidden
{
    return NO;
}

- (RCDScrollView *)bgScrollView
{
    if (!_bgScrollView) {
        _bgScrollView = [RCDScrollView new];
        
        [self.view addSubview:_bgScrollView];
        
        [_bgScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_equalTo(self.view.safeAreaInsets);
        }];
        
        _bgScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    return _bgScrollView;
}

- (void)didReceiveMemoryWarning
{
//    [super didReceiveMemoryWarning];
}

@end
